<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
   <%@page import="it.polimi.travelDream.ejb.servlet.*" %>
    <%@page import="it.polimi.travelDream.entities.*" %>
     <jsp:useBean id="tmgr" class="it.polimi.travelDream.ejb.beans.TransportationMgr" scope="session" />
     
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>
		  	TravelDreamLogin
		</title>
		<link rel="stylesheet" type="text/css" href="style.css" />
  	</head>
  
  
  <body>
  	<div class="header">
  		<ul>
	  		<li>TravelDream</li>
		    Manage Packages
	    </ul>
  	</div> 
  	
  	<div class="section">	    
 <div class="nav">
	    	<ul>
	    		<li> <a href="StaffHome.jsp">Home</a></li>
	    		<li> <a href="BPManagement.jsp">Manage BasicProducts</a></li>
	    		<li class="cur"> <a href="PManagement.jsp"> Manage Packages</a></li>
	    			<ul class="submenu">
						<li class="cur">Create Package</li>
						<li>Remove Package</li>
					</ul>
					<% 
	    		Staff z = new Staff(0,false,"0","0","0","0","0");
	      		if (request.getSession().getAttribute("utente")!=null )
		    	{ 
	      			z=(Staff)request.getSession().getAttribute("utente");
		        }
	      		else
	      		{
	      			
	      		}
	    		if (z.isPermission())
	    		{
	    			out.println("<li><a href=StaffRegistration.jsp> Manage Staff </a></li>");
	    		}
		    	
	    
		    		%>
	    		<li> <a href="/TravelDreamSystemWeb/StaffLogoutServlet?session=0"> Logout </a></li>
	    	</ul>
	    </div>
	    <div class="content">
	    	 <% 
	      if (request.getSession().getAttribute("utente")!=null )
		    	{ Staff u=(Staff)request.getSession().getAttribute("utente");
		    		System.out.println("ciao"+u.getId());
		    	
	    
		    		%>
	     <div class="spacer"></div>  
	       <% 
	    	if (request.getAttribute("message") == null) 
		    	{ 
		    		%>
						<div></div>
					<% 
				} 
	    	else 
		    	{ 
		    		%>
						<div class="advice"><%=request.getAttribute("message")%></div>
					<% 
				} 
		%>
		<div class="spacer"></div> 
			
			        <div class=record>
        			
	        			<div class=recordfield>
	        				Type
	        			</div>
	        			
	        			<div class=recordfield>
	        				Dep. 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Arr.
	        			</div>
	        		
	        			
	        			<div class=recordfield>
	        				Dep.Time 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Arr.Time 
	        			</div>
	        			
	        			<div class=recordfield>
	        				Cost
	        			</div>
	        			
	        			<div class=recordfield>
	        				 
	        			</div>
	        			
	        		    <div class=recordfield>
	        				 
	        			</div>
        						    	
	    			</div>
		     <%
        		int i = tmgr.showAllTransportation().size() - 1;
		     	out.println("<form action=AddPackageTravels method=POST >") ;
        		while (i>=0) {
        			out.println("<div class=record>");
        			
        			out.println("<div class=recordfield>") ;
        			out.println(tmgr.showAllTransportation().get(i).getTypeTransportation());
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println(tmgr.showAllTransportation().get(i).getDepartureFrom());
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println(tmgr.showAllTransportation().get(i).getGoingTo());
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println(tmgr.showAllTransportation().get(i).getOutBound());
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println(tmgr.showAllTransportation().get(i).getInBound());
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println(tmgr.showAllTransportation().get(i).getCost());
        			out.println("</div>") ;
        			
        			out.println("<div class=recordfield>") ;
        			out.println("<input class=smallinput type=checkbox name=idTransportation"+i+" value="+tmgr.showAllTransportation().get(i).getid()+" >");        			
        			out.println("<input type=hidden name=idPackage value="+request.getAttribute("idPackage")+" >");
        			out.println("</div>") ;
        			
        			out.println("</div>");
        			i--;
	    			
        		}
 
    			out.println("<input class=centeredbutton type=submit value=Next />");

    			out.println("</form>") ;
        		
    		%>		    
    		
    		
    		
    		
    			 
    		
    		
		</div>
<%
		} else { 
				response.sendRedirect("/TravelDreamSystemWeb/StaffLogin.jsp");
				%>
				
				
					<%
		}	
		%>
    </div>
    
    <div class="footer">
    	<ul>
	    	<li>TravelDream Company srl © All rights reserved</li>
		    <li>Terms of use | Contacts | Team </li>
	    </ul>
    </div>
    
  </body>
</html>